home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.5)
-
- import os
- import util
- import config
- import _winreg
- import cPickle
- import string
- import prefs
- import tempfile
- import ctypes
- import resources
- import proxyfind
- proxy_info = proxyfind.get_proxy_info()
- _specialFolderCSIDLs = {
- 'AppData': 26,
- 'My Music': 13,
- 'My Pictures': 39,
- 'My Videos': 14,
- 'My Documents': 5,
- 'Desktop': 0,
- 'Common AppData': 35 }
-
- def getSpecialFolder(name):
- """Get the location of a special folder. name should be one of the
- following: 'AppData', 'My Music', 'My Pictures', 'My Videos',
- 'My Documents', 'Desktop'.
-
- The path to the folder will be returned, or None if the lookup fails
-
- """
- buf = ctypes.create_unicode_buffer(260)
- buf2 = ctypes.create_unicode_buffer(1024)
- SHGetSpecialFolderPath = ctypes.windll.shell32.SHGetSpecialFolderPathW
- GetShortPathName = ctypes.windll.kernel32.GetShortPathNameW
- csidl = _specialFolderCSIDLs[name]
- if SHGetSpecialFolderPath(None, buf, csidl, False):
- if GetShortPathName(buf, buf2, 1024):
- return buf2.value
- else:
- return buf.value
- else:
- return None
-
- _appDataDirectory = getSpecialFolder('AppData')
- _commonAppDataDirectory = getSpecialFolder('Common AppData')
- _baseMoviesDirectory = getSpecialFolder('My Videos')
- _nonVideoDirectory = getSpecialFolder('Desktop')
- if _baseMoviesDirectory is None:
- _baseMoviesDirectory = os.path.join(getSpecialFolder('My Documents'), 'My Videos')
-
-
- def _getMoviesDirectory():
- path = os.path.join(_baseMoviesDirectory, config.get(prefs.SHORT_APP_NAME))
-
- try:
- os.makedirs(os.path.join(path, 'Incomplete Downloads'))
- except:
- pass
-
- return path
-
-
- def _getSupportDirectory():
- path = os.path.join(_appDataDirectory, u'Participatory Culture Foundation', u'Miro', u'Support')
-
- try:
- os.makedirs(path)
- except:
- pass
-
- return path
-
-
- def _getThemeDirectory():
- path = os.path.join(_commonAppDataDirectory, u'Participatory Culture Foundation', u'Miro', u'Themes')
-
- try:
- os.makedirs(path)
- except:
- pass
-
- return path
-
-
- def _getConfigFile():
- return os.path.join(_getSupportDirectory(), 'preferences.bin')
-
-
- def load():
-
- try:
- file = _getConfigFile()
- if os.path.exists(file):
- return cPickle.load(open(file))
- else:
- return { }
- except:
- import traceback
- print 'Error loading perferences. Resetting prefs.'
- traceback.print_exc()
- return { }
-
-
-
- def save(data):
- file = _getConfigFile()
- cPickle.dump(data, open(file, 'w'))
-
-
- def get(descriptor):
- if descriptor == prefs.MOVIES_DIRECTORY:
- return _getMoviesDirectory()
- elif descriptor == prefs.THEME_DIRECTORY:
- return _getThemeDirectory()
- elif descriptor == prefs.NON_VIDEO_DIRECTORY:
- return _nonVideoDirectory
- elif descriptor == prefs.GETTEXT_PATHNAME:
- return resources.path('locale')
- elif descriptor == prefs.SUPPORT_DIRECTORY:
- return _getSupportDirectory()
- elif descriptor == prefs.ICON_CACHE_DIRECTORY:
- return os.path.join(_getSupportDirectory(), 'icon-cache')
- elif descriptor == prefs.DB_PATHNAME:
- path = get(prefs.SUPPORT_DIRECTORY)
- return os.path.join(path, 'tvdump')
- elif descriptor == prefs.BSDDB_PATHNAME:
- path = get(prefs.SUPPORT_DIRECTORY)
- return os.path.join(path, 'database')
- elif descriptor == prefs.SQLITE_PATHNAME:
- path = get(prefs.SUPPORT_DIRECTORY)
- return os.path.join(path, 'sqlitedb')
- elif descriptor == prefs.LOG_PATHNAME:
- return os.path.join(tempfile.gettempdir(), '%s.log' % config.get(prefs.SHORT_APP_NAME))
- elif descriptor == prefs.DOWNLOADER_LOG_PATHNAME:
- return os.path.join(tempfile.gettempdir(), '%s-downloader.log' % config.get(prefs.SHORT_APP_NAME))
- elif descriptor == prefs.RUN_AT_STARTUP:
- folder = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Run')
- count = 0
- while True:
-
- try:
- (name, val, type) = _winreg.EnumValue(folder, count)
- count += 1
- if name == config.get(prefs.LONG_APP_NAME):
- return True
- continue
- return False
- continue
-
- return False
- elif descriptor == prefs.HTTP_PROXY_ACTIVE:
- return proxy_info.host is not None
- elif descriptor == prefs.HTTP_PROXY_HOST:
- return proxy_info.host
- elif descriptor == prefs.HTTP_PROXY_PORT:
- return proxy_info.port
- elif descriptor == prefs.HTTP_PROXY_IGNORE_HOSTS:
- return poxy_info.ignore_hosts
- else:
- return descriptor.default
-
-